<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">   

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </h:head>

    <h:body>

	<ui:composition>
	    <p:dialog id="pnConsultarImovel" closable="false" showHeader="true" widgetVar="pnConsultarImoveis" resizable="false" width="950"
		      maximizable="true" modal="true" position="top">
		<f:facet name="header">
		    #{msg.decretoImovelDecretosAssociados}
		</f:facet>
		<h:form id="fConsultarImoveis">
		    <p:messages for="modal" closable="true" autoUpdate="true" escape="false"/> 
		    <p:fieldset id="fsParamConsultaImoveis">
			<h:panelGrid columns="3">
			    <h:panelGrid columns="1">
				<p:outputLabel for="itEmpreendimento" value="#{msg.imovelEmpreendimento}"/>
				<p:inputText id="itEmpreendimento" value="#{imovelDecreto.parametros.empreendimento}" size="68"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itBairro" value="#{msg.imovelBairro}"/>
				<p:inputText id="itBairro" value="#{imovelDecreto.parametros.bairro}" size="68"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itCodigoXPLAN" value="#{msg.imovelCodigoXPLAN}"/>
				<p:inputText id="itCodigoXPLAN" value="#{imovelDecreto.parametros.codigoXPLAN}" />
			    </h:panelGrid>			
			</h:panelGrid>
			<h:panelGrid columns="5">
			    <h:panelGrid columns="1">
				<p:outputLabel for="itQuadra" value="#{msg.imovelQuadra}"/>
				<p:inputText id="itQuadra" value="#{imovelDecreto.parametros.quadra}"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itLote" value="#{msg.imovelLote}"/>
				<p:inputText id="itLote" value="#{imovelDecreto.parametros.lote}"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itCT" value="#{msg.imovelCT}"/>
				<p:inputText id="itCT" value="#{imovelDecreto.parametros.ct}"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itCTM01" value="#{msg.imovelCTM}"/>
				<h:panelGroup id="pgCTM">
				    <p:inputText id="itCTM01" value="#{imovelDecreto.parametros.ctmSetor}" size="2" maxlength="2"/>
				    <p:inputText id="itCTM02" value="#{imovelDecreto.parametros.ctmQuadra}" size="5" maxlength="5"/>
				    <p:inputText id="itCTM03" value="#{imovelDecreto.parametros.ctmImovel}" size="5" maxlength="5"/>
				</h:panelGroup>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="somRegional" value="#{msg.imovelRegional}"/>
				<p:selectOneMenu id="somRegional" style="width: 310px" value="#{imovelDecreto.parametros.idRegional}">
				    <f:selectItems value="#{imovelDecreto.listaRegionais}"/>
				</p:selectOneMenu>
			    </h:panelGrid>
			</h:panelGrid>
			<h:panelGrid columns="2">
			    <h:panelGrid columns="1">
				<p:outputLabel for="itPessoa" value="#{msg.imovelPessoa}"/>
				<p:inputText id="itPessoa" size="82" value="#{imovelDecreto.parametros.pessoa}"/>
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="itLogradouro" value="#{msg.imovelLogradouro}"/>
				<p:inputText id="itLogradouro" size="82" value="#{imovelDecreto.parametros.logradouro}"/>
			    </h:panelGrid>
			</h:panelGrid>

			<div class="espacamento"/>

			<p:commandButton value="#{msg.pesquisar}"
					 action="#{imovelDecreto.pesquisarImoveis}"
					 icon="ui-icon-search"
					 update="opImoveis"
					 process="@this, fsParamConsultaImoveis"/>

		    </p:fieldset>

		    <div class="espacamento"/>

		    <p:outputPanel id="opImoveis">
			<p:dataTable id="dtImoveis"
				     value="#{imovelDecreto.dataModel}"
				     var="imovel"
				     paginator="true"
				     lazy="true"
				     paginatorPosition="bottom"
				     paginatorAlwaysVisible="false"
				     rows="#{imovelDecreto.registrosPorPagina}"
				     rowKey="#{imovel.id}"
				     selection="#{imovelDecreto.imoveisSelecionados}"
				     rowsPerPageTemplate="#{imovelDecreto.linhasPorPagina}"
				     emptyMessage="#{msg.nenhumRegistroEncontrado}"
				     rendered="#{not empty imovelDecreto.dataModel}">

			    <p:column selectionMode="multiple" style="width:30px;" /> 

			    <p:column headerText="#{msg.decretoImovelBairro}">
				#{imovel.bairro}
			    </p:column>

			    <p:column headerText="#{msg.decretoImovelQuadra}">
				#{imovel.quadra}
			    </p:column>

			    <p:column headerText="#{msg.decretoImovelLote}">
				#{imovel.lote}
			    </p:column>

			    <p:column headerText="#{msg.decretoImovelCT}">
				#{imovel.ct}
			    </p:column>
			    
			    <p:column headerText="#{msg.imovelEmpreendimento}">	
				<ui:repeat value="#{imovel.imoveisEmpreendimentos}" var="emp">
				    #{emp.empreendimento.nome}<br/>
				</ui:repeat>
			    </p:column>

			</p:dataTable>
		    </p:outputPanel>

		    <div class="espacamento"/>

		    <div align="left">
			<p:commandButton id="btSelecionar"
					 action="#{imovelDecreto.selecionarDecretos}"
					 icon="ui-icon-plus"
					 value="#{msg.confirmar}"
					 oncomplete="pnConsultarImoveis.hide();"
					 process="@this, :fConsultarImoveis:opImoveis"
					 update=":fDecretoImovel:dtDecretoImovel"/>
			<p:spacer width="5"/>
			<p:commandButton id="btVoltar"
					 icon="ui-icon-close"
					 value="#{msg.cancelar}"
					 immediate="true"
					 onclick="pnConsultarImoveis.hide();"/>
		    </div>
		</h:form>
	    </p:dialog>
	</ui:composition>

    </h:body>

</html>
